import { memo } from 'react'
import { useSearchParams } from 'react-router-dom'
import { Space, Button } from 'antd'

const index = memo(() => {
  let [searchParams, setSearchParams] = useSearchParams();

  return (
    <div>
      <h1>menu1：useSearchParams的使用</h1>
      <Space>
        <Button type='primary' onClick={() => {
          console.log(searchParams.toString());
        }}>获取查询参数</Button>
        <Button type='primary' onClick={() => {
          setSearchParams({
            name: '李四',
            age: '28',
            sex: '男'
          })
        }}>设置SearchParams</Button>
        <Button type='primary' onClick={() => {
          setSearchParams({})
        }}>清空SearchParams</Button>
      </Space>
    </div>
  )
})

export default index